﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Utils;
using Utils.DatabaseUtils;

namespace Entity
{
    public class OrderDetailUI
    {
        private int _O_ID;

        public int O_ID
        {
            get { return _O_ID; }
            set { _O_ID = value; }
        }

        private int _I_ID;

        public int I_ID
        {
            get { return _I_ID; }
            set { _I_ID = value; }
        }

        private int _Size_ID;

        public int Size_ID
        {
            get { return _Size_ID; }
            set { _Size_ID = value; }
        }

        private float _Price;

        public float Price
        {
            get { return _Price; }
            set { _Price = value; }
        }

        private int _Quantity;

        public int Quantity
        {
            get { return _Quantity; }
            set { _Quantity = value; }
        }


        public OrderDetailUI() { }

        public OrderDetailUI(int O_ID, int I_ID, int SizeID, float Price, int Quantity)
        {
            this.O_ID = O_ID;
            this.I_ID = I_ID;
            this.Size_ID = SizeID;
            this.Price = Price;
            this.Quantity = Quantity;
        }

        public int Add(int O_ID, int I_ID, int SizeID, float Price, int Quantity)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderDetail_add", O_ID, I_ID, SizeID, Price, Quantity);
                return result;
            }
            catch (Exception e) { return -1; }
        }

        public int Update(int O_ID, int I_ID, int SizeID, float Price, int Quantity)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderDetail_update", O_ID, I_ID, SizeID, Price, Quantity);
                return result;
            }
            catch (Exception e) { return -1; }
        }

        public int Delete(int O_ID, int I_ID, int SizeID)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderDetail_delete", O_ID, I_ID, SizeID, Price);
                return result;
            }
            catch (Exception e) { return -1; }
        }

        public DataSet Get(int O_ID)
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "OrderDetail_get", O_ID);
                return result;
            }
            catch (Exception e) { return null; }
        }

        public DataSet GetAll()
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "OrderDetail_getall");
                return result;
            }
            catch (Exception e) { return null; }
        }


        
    }
}
